package com.app.util.web;


public class HTMLUtil { 

	public static String toHTML(String s) {
		s = s.replaceAll("&", "&amp;");
		s = s.replaceAll(" ", "&nbsp;");
		s = s.replaceAll(">", "&gt;");
		s = s.replaceAll("<", "&lt;");
		s = s.replaceAll("\"", "&quot;");
		s = s.replaceAll("\\\r\\\n", "<br/>");
		s = s.replaceAll("\\\r", "<br/>");
		s = s.replaceAll("\\\n", "<br/>");
		return s;
	}

	public static String toRichHTML(String s) {
		s = s.replaceAll("&", "&amp;");
		s = s.replaceAll(" ", "&nbsp;");
		s = s.replaceAll(">", "&gt;");
		s = s.replaceAll("<", "&lt;");
		s = s.replaceAll("\"", "&quot;");
		s = s.replaceAll("\\\r\\\n", "\n");
		s = s.replaceAll("\\\r", "<br/>");
		String[] ss = s.split("\\\n");
		StringBuffer sb = new StringBuffer();
		for (String _ : ss) {
			sb.append("<p>").append(_).append("</p>");
		}

		return sb.toString();
	}

}
